/**HEADER********************************************************************
* 
* Copyright (c) 2011 Freescale Semiconductor;
* All Rights Reserved
*
*************************************************************************** 
*
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR 
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
* THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************
*
* $FileName: timer_mcf51ac.c$
* $Version : 3.8.1.0$
* $Date    : May-11-2011$
*
* Comments:
*
*   This file contains timer functions for use with a MCF51AC.
*
*END************************************************************************/

#include <mqx.h>
#include <bsp.h>
#include "timer_tpm.h"


/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_get_tpm_base_address
* Returned Value   : Address upon success, NULL upon failure
* Comments         :
*    This function returns the base register address of the corresponding TPM
*
*END*----------------------------------------------------------------------*/

pointer _bsp_get_tpm_base_address (uint_8 timer)
{
    volatile MCF51AC_STRUCT _PTR_ reg_ptr = _PSP_GET_MBAR();
    return (pointer)&reg_ptr->TPM3;
}


/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_tpm_clk_en
* Returned Value   : Address upon success, NULL upon failure
* Comments         :
*    This function enables clock to corresponding TPM
*
*END*----------------------------------------------------------------------*/
void _bsp_tpm_clk_en (uint_8 timer)
{
    volatile MCF51AC_STRUCT _PTR_ reg_ptr = _PSP_GET_MBAR();
    reg_ptr->SIM.SCGC1 |= MCF51XX_SCGC1_TPM3_MASK;  
}
